/**
 * 
 */

/**
 * @author osamie
 *
 */
public class Negate extends Operator {
	
	//private Data s;
	/**
     * Return the number of arguments this operator takes
     */
    public int nArguments() {
	return 1;
    }

   
    
    /**
     * Evaluate this operator on the given expression
     */
    public Data evaluate(Data args[]) throws TypeException {
    	
    	if ((args[0] instanceof NumberData)) {
    		
    		
			NumberData b = (NumberData)args[0];
			
			if (b.value == 0){return new NumberData(b.value);}
			//if ((b.value > 0)|(b.value < 0)){return new }
			
			if (b.value > 0) {return new NumberData(-(b.value));}
			
			
			throw new TypeException(getClass().getName()
					+ ": Sorry multi negation {e.g --9 or -(-9)} operation not allowed");
			//return new NumberData((b.value));
			
			
    	}   		

	throw new TypeException(getClass().getName()
			+ ": Argument is not a number");
		
	
    }

    /**
     * Return a string representation of this operator
     */
    public String toString() {
	return "-";
    }

}